// Town script for town 21: underground gate

begintownscript;

variables;

int choice;

body;

beginstate INIT_STATE;
break;

beginstate EXIT_STATE;
set_flag(21,4,0);
break;

beginstate START_STATE;
set_flag(275,5,21); // necessary for town 20 start_state
break;

beginstate 10;
if (get_flag(21,4) == 0) { // If you didn't open gates yet, run code. otherwise not

if (get_flag(5,7) == 1) {
		if (get_flag(8,10) == 1) {
			message_dialog("You think of a spell to open these gates. There are two you know: Benthol's spell and the castle one. As the castle one seems more likely, you say it.","When you slowly begin to say the words, life returns to the old gates. They open.");
			set_terrain(23,5,32);
			set_terrain(24,5,32);
			set_terrain(25,5,32);
			set_terrain(23,38,32);
			set_terrain(24,38,32);
			set_terrain(25,38,32);
			set_flag(21,4,1);
			end();
			}
		message_dialog("You say the spell you know: Benthol's spell. However, the spell Benthol told you doesn't seem to work. Its probably not the right spell for this particular gate.","");
		end();
		}
	message_dialog("The gates here are closed. There is no lever or wheel, which suggests a spell. What a shame you don't know the right spell for these gates.","");
}
break;

beginstate 11;
if (get_flag(21,0) == 1)
		end();
	message_dialog("In the middle of the fort there is a small pond. There are stepping stones to a small island that lies in the middle of it. You think you see a small humanoid body lying on the island.","");
	set_flag(21,0,1);
break;

beginstate 12;
if (get_flag(21,1) == 1)
		end();
	message_dialog("This is where the Senarti presumably eat and feast. There are rows of tables and nice fires to keep the place warm. There are also bookshelves. One can read a book, if he wishes.","The amount of books on the shelves is enormous. You presume that many Senarti must be able to read, then. Another sign of the intellect of the Senarti.");
	set_flag(21,1,1);
break;

beginstate 13;
if (get_flag(21,2) == 1)
		end();
	message_dialog("The small graveyard isn't full at all. The Senarti must be able to keep health up despite these cold and humid caves. Unlike Avernum, where warm springs and the like keep the place warm, it is quite cold here.","");
	set_flag(21,2,1);
break;

beginstate 14;
if (get_flag(21,3) == 1)
		end();
	message_dialog("This is the office of the fort's chief. It is roomy and clear that the chief doesn't like to have many things in his room. It is very empty, actually. Nothing more than what is strictly necessary.","");
	set_flag(21,3,1);
break;
